package crack.lshape.q4mesh2;

import java.io.IOException;

import math2.MathUtilities;
import crack.AbstractLshapeUsingSDAElementDemo;
import fem2.AbstractStructuralCrackDemo;
import fem2.Element;
import fem2.MaterialModel;
import fem2.MeshPart;
import fem2.Model;
import fem2.element.crack_sda.SOSConstantJumpElement;
import fem2.material.cohesive_law.CohesiveLaw;
import fem2.material.cohesive_law.Mode1SanchoExponentialCohesiveLaw;
import fem2.observer.StressObserver;
import fem2.observer.TimeStepObserver;
import fem2.strategies.Strategy;

public class Q4mesh2_SOSConstantJumpElement_SanchoCohesiveLaw extends
		AbstractLshapeUsingSDAElementDemo {

	public Q4mesh2_SOSConstantJumpElement_SanchoCohesiveLaw() {
		meshFileName = "q4mesh2-sos-sancho.msh";
	}

	@Override
	public CohesiveLaw createCohesiveLaw(Model m) {
		double ft = 2.7;
		double Gf = 0.065;
		return new Mode1SanchoExponentialCohesiveLaw(Gf, ft);
	}

	@Override
	public Element createElement(MeshPart mp, MaterialModel mm, CohesiveLaw cl) {
		Element e = new SOSConstantJumpElement(mp, mm, cl);
		// e.setEchoLevel(EchoLevelType.OUTPUT);
		return e;
	}

	@Override
	public void addObservers(Model m, Strategy s, TimeStepObserver o) {
		super.addObservers(m, s, o);

		s.addObserver(new StressObserver(m));
	}

	public static void main(String[] args) throws IOException {

		AbstractStructuralCrackDemo sample = new Q4mesh2_SOSConstantJumpElement_SanchoCohesiveLaw();

		// double[] lambda = MathUtilities.createLambdaArray(13.84, 0.1, 15.0);

		double[] lambda = MathUtilities.createLambdaArray(13.84, 0.1, 25.0); // bad
																				// result

		sample.run(lambda);

	}
}
